<template>
  <div>
    <el-table
      :data="tableData"
      :span-method="objectSpanMethod"
      border
      style="width: 100%; margin-top: 20px; font-size: 20px"
      :header-cell-style="{ background: '#34adfc', color: '#fff' }"
    >
      <!-- <el-table-column prop="id" label="ID" width="180"> </el-table-column> -->
      <el-table-column prop="name" label="病理所见"> </el-table-column>
      <el-table-column
        v-for="(item, index) in tableData.length - 1"
        :key="index"
        prop="amount"
        :label="title[index]"
      >
      {{tableData[index].amount[index]}}
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      title: ['','无', '中', '轻', '重'],
      tableData: [
        {
          id: "12987122",
          name: "肾小球异常",
          amount: ["细胞改变","0", "1", "2", "3"],
        },
        {
          id: "12987123",
          name: "肾小球异常",
          amount: ["细胞改变","0", "1", "2", "3"],
        },
        {
          id: "12987124",
          name: "肾小球异常",
          amount: ["细胞改变", "0", "1", "2", "3"],
        },
        {
          id: "12987125",
          name: "肾小球异常",
          amount: ["细胞改变", "0", "1", "2", "3"],
        },
        {
          id: "12987126",
          name: "肾小球异常",
          amount: ["细胞改变", "0", "1", "2", "3"],
        },
        {
          id: "12987126",
          name: "肾小管间质的异常",
          amount: ["细胞改变" ,"0", "1", "2", "3"],
        },
      ],
    };
  },
  methods: {
    // arraySpanMethod({ row, column, rowIndex, columnIndex }) {
    //   if (rowIndex === 0) {
    //     if (columnIndex === 0) {
    //       return [1, 2];
    //     } else if (columnIndex === 1) {
    //       return [0, 0];
    //     }
    //   }
    // },

    objectSpanMethod({ rowIndex, columnIndex }) {
      if (columnIndex === 0) {
        if (rowIndex % 5 === 0) {
          return {
            rowspan: 5,
            colspan: 1,
          };
        } else {
          return {
            rowspan: 0,
            colspan: 0,
          };
        }
      }
    },
  },
};
</script>

<style>
.border {
  padding: 15px 20px;
  font-size: 20px;
  border: 1px solid #ebeef5;
  margin-top: -1px;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
  width: 100%;
}

td,
th {
  padding: 0;
}

.pure-table {
  border-collapse: collapse;
  border-spacing: 0;
  empty-cells: show;
  border: 1px solid #ebeef5;
}

.pure-table caption {
  color: #000;
  font: italic 85%/1 arial, sans-serif;
  padding: 1em 0;
  text-align: center;
}

.pure-table td,
.pure-table th {
  border-left: 1px solid #ebeef5;
  border-width: 0 0 0 1px;
  font-size: inherit;
  margin: 0;
  overflow: visible;
  padding: 0.5em 1em;
}

.pure-table thead {
  background-color: rgb(238, 241, 246);
  color: #000;
  text-align: left;
  vertical-align: bottom;
}

.pure-table td {
  background-color: transparent;
}

.pure-table-bordered td {
  border: 1px solid #ebeef5;
}

.pure-table-bordered tbody > tr:last-child > td {
  border-bottom-width: 0;
}
</style>
